package com.farm.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.farm.common.AppHttpCodeEnum;
import com.farm.common.ResponseResult;
import com.farm.pojo.Logs;
import com.farm.service.LogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author farm
 * @since 2023-12-21
 */
@RestController
@RequestMapping("/logs")
public class LogsController {
    @Autowired
    private LogsService logsService;
    @GetMapping("/admin/getlist")
    public ResponseResult logsList(int current, int size){
        Page pageInfo = new Page(current,size);
        return ResponseResult.okResult(logsService.page(pageInfo));
    }

    @PostMapping("/admin/delete")
    public ResponseResult delete(@RequestBody Logs logs){
        boolean b = logsService.removeById(logs.getId());
        return b?ResponseResult.okResult(AppHttpCodeEnum.SUCCESS):ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

}

